import java.awt.*;
import javax.swing.JFrame;

/*
 * This class manage initializing and displaying full screen graphs mode
 */

public class SimpleScreenManager {

	private GraphicsDevice device;
	
	//Creates mannager object
	public SimpleScreenManager()
	{
		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		device= environment.getDefaultScreenDevice();
	}
	
	//enters full screen mode and set mode
	
	public void setFullScreen(DisplayMode displayMode, JFrame window)
	{
		window.setUndecorated(true);
		window.setResizable(false);
		
		device.setFullScreenWindow(window);
		if (displayMode!=null && device.isDisplayChangeSupported())
		{
			try{
				device.setDisplayMode(displayMode);
			}
			catch (IllegalArgumentException ex)
			{
				//--illegal mode for the device
			}
		}
		
	}
	
	
	//returns windows
	
	public Window getFullScreenWindow()
	{
		return device.getFullScreenWindow();
	}
	
	//rESTORES THE DISPLAy mode
	
	public void restoreScreen()
	{
		Window window = device.getFullScreenWindow();
		if(window!=null)
		{
			window.dispose();
		}
		device.setFullScreenWindow(null);
	}

}
